package com.bondqin.demo.util;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class ResultModel {

	private boolean success;
	
	private String error;
	
	private List<String> errorList;
	
	private Map<String, Object> model = new HashMap<String, Object>();

	public boolean isSuccess() {
		return success;
	}

	public void setSuccess(boolean success) {
		this.success = success;
	}

	public String getError() {
		return error;
	}

	public void setError(String error) {
		this.error = error;
	}

	public void addError(String error) {
		if (errorList == null) {
			errorList = new ArrayList<String>();
		}
		errorList.add(error);
	}
	
	public void put(String key, Object value) {
		model.put(key, value);
	}
	
	public Map<String, Object> toMap() {
		model.put("success", success);
		model.put("error", error);
		model.put("errorList", errorList);
		
		return model;
	}

}
